require 'watir'
include Watir
require 'test/unit'
class TC_blogsFrontEnd < Test::Unit::TestCase
  	def test_44_ModifyBlogGroupUsingDropDownBox_Blogs

  $ie.goto($UniVar)

#Create Blog
	$ie.goto($UniVar + '/controlpanel/BlogAdmin/sectionedit.aspx')	
	$ie.text_field(:id, /ctl00_ctl00_TaskRegion_SectionDetails1_SectionDetails1_SectionName/).set('rewriteblog')
	$ie.text_field(:id, /ctl00_ctl00_TaskRegion_SectionDetails1_SectionDetails1_AppKey/).set('rewriteblog')
	$ie.text_field(:id, /ctl00_ctl00_TaskRegion_SectionDetails1_SectionDetails1_Owners/).set($ADMIN)  
	$ie.link(:text, 'Save').click
  
#Create Blog Group
  $ie.goto($UniVar + '/controlpanel/blogAdmin/Groups.aspx')
	$ie.link(:text, 'Add New Group').click
  $ie.frame(:index, 1).text_field(:id, /GroupName$/).value = 'Some name'
  $ie.frame(:index, 1).text_field(:id, /GroupDesc$/).value = 'Some description'
  $ie.frame(:index, 1).link(:id, /SaveButton$/).click
  
#Test Specifics
	$ie.goto($UniVar + '/controlpanel/BlogAdmin/Groups.aspx')		
  $ie.link(:index, 21).click
  $ie.link(:text, 'rewriteblog').click
	$ie.select_list(:id, /ctl00_ctl00_TaskRegion_SectionDetails1_SectionDetails1_AdminGroupList/).select('Some name')
	$ie.link(:text, 'Save').click
	assert($ie.contains_text('Some name'))

  #Delete Blog
  $ie.goto($UniVar + '/controlpanel/BlogAdmin/Blogs.aspx')
  $ie.wait()
  $ie.link(:text, 'Delete').click_no_wait
  hwnd = $ie.enabled_popup(20)
    if(hwnd)
      w = WinClicker.new
      w.clickWindowsButton_hwnd(hwnd, "OK")
    end        

#Delete Blog Group
    $ie.goto('http://localhost/cs/controlpanel/blogAdmin/Groups.aspx')
    $ie.div(:index, 61).click
    $ie.div(:index, 61).click    
    $ie.link(:text, 'Delete').click_no_wait
      hwnd = $ie.enabled_popup(5)
      if(hwnd)
        w = WinClicker.new
        w.clickWindowsButton_hwnd(hwnd, "OK")
      end
      
	end
end